package com.unionpay.mobile.android.pboctransaction.remoteapdu;

import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import com.unionpay.mobile.android.pboctransaction.AppIdentification;
import com.unionpay.mobile.android.pboctransaction.d;
import com.unionpay.mobile.android.pboctransaction.e;
import com.unionpay.mobile.android.utils.h;
import com.unionpay.mobile.tsm.connect.IInitCallback.Stub;
import com.unionpay.mobile.tsm.connect.IRemoteApdu;
import java.util.ArrayList;
import java.util.Iterator;

public final class a
  implements com.unionpay.mobile.android.pboctransaction.c
{
  com.unionpay.mobile.android.pboctransaction.b a;
  private IRemoteApdu b = null;
  private boolean c = false;
  private Context d = null;
  private final ServiceConnection e = new b(this);
  private final IInitCallback.Stub f = new c(this);

  public final ArrayList<com.unionpay.mobile.android.model.c> a(d paramd)
  {
    h.a("plugin-tsm", "RemoteApduEngine.readList() +++");
    Object localObject;
    try
    {
      if (this.c);
      for (String str2 = "D15600010100016111000000B0004101"; ; str2 = "D15600010100016111000000B0004001")
      {
        h.a("plugin-tsm", "sid=" + str2);
        String str3 = this.b.writeApdu("00a4040010" + str2, 0);
        if ((str3 != null) && (str3.equalsIgnoreCase("9000")))
          str3 = this.b.writeApdu("80CA2F0000", 0);
        ArrayList localArrayList3 = e.b(str3);
        localArrayList1 = localArrayList3;
        localObject = null;
        if (localArrayList1 == null)
          break label281;
        int i = localArrayList1.size();
        localObject = null;
        if (i <= 0)
          break label281;
        localArrayList2 = new ArrayList();
        Iterator localIterator = localArrayList1.iterator();
        while (localIterator.hasNext())
        {
          AppIdentification localAppIdentification = (AppIdentification)localIterator.next();
          if (!"06".equalsIgnoreCase(localAppIdentification.b()))
          {
            String str1 = e.c(paramd.a(localAppIdentification));
            if ((str1 != null) && (str1.length() > 0))
              localArrayList2.add(new com.unionpay.mobile.android.model.a(4, localAppIdentification.a(), "", str1, 1));
          }
        }
      }
    }
    catch (Exception localException)
    {
      ArrayList localArrayList2;
      while (true)
      {
        localException.printStackTrace();
        h.c("plugin-tsm", localException.getMessage());
        ArrayList localArrayList1 = null;
      }
      localObject = localArrayList2;
      label281: h.a("plugin-tsm", "RemoteApduEngine.readList() ---");
    }
    return localObject;
  }

  public final void a()
  {
    d();
    if (this.d != null)
    {
      Context localContext = this.d;
      h.a("plugin-tsm", "unbindTSMService() ++");
      new Intent("com.unionpay.mobile.tsm.PBOCService").setPackage("com.unionpay.mobile.tsm");
      localContext.unbindService(this.e);
    }
  }

  public final void a(com.unionpay.mobile.android.pboctransaction.b paramb, Context paramContext)
  {
    this.a = paramb;
    this.d = paramContext;
    Intent localIntent = new Intent("com.unionpay.mobile.tsm.PBOCService");
    localIntent.setPackage("com.unionpay.mobile.tsm");
    paramContext.startService(localIntent);
    if ((!paramContext.bindService(localIntent, this.e, 1)) && (this.a != null))
    {
      h.a("plugin-tsm", "startTSMService.initFailed()");
      this.a.b();
    }
  }

  public final void a(boolean paramBoolean)
  {
    this.c = paramBoolean;
  }

  public final byte[] a(byte[] paramArrayOfByte, int paramInt)
  {
    if (paramArrayOfByte == null)
      return null;
    String str1 = e.a(paramArrayOfByte, paramArrayOfByte.length);
    h.a("plugin-tsm", "[---->]" + str1);
    try
    {
      String str3 = this.b.writeApdu(str1, paramInt);
      str2 = str3;
      h.a("plugin-tsm", "[<----]" + str2);
      return e.a(str2);
    }
    catch (Exception localException)
    {
      while (true)
      {
        localException.printStackTrace();
        String str2 = null;
      }
    }
  }

  public final void b()
  {
  }

  public final void c()
  {
    d();
  }

  public final void d()
  {
    if (this.b != null);
    try
    {
      this.b.closeChannel(0);
      this.b.closeChannel(1);
      this.b.closeChannel(2);
      return;
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.unionpay.mobile.android.pboctransaction.remoteapdu.a
 * JD-Core Version:    0.6.2
 */